package com.video.main_video.dao.enums;

import java.util.Objects;

public enum CardType {

    DAY("日卡",1),
    MONTH("月卡",2),
    YEAR("年卡",3),
    WEEKDAY("周卡",4),
    ;
    private String name;
    private int code;

    private CardType(String name,int code){
        this.name=name;
        this.code=code;
    }


    // 通过code获取名称
    public static String formName(int code) {
        for (CardType c : CardType.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }

    // 通过名称获取code
    public static Integer formCode(Class name) {
        for (CardType c : CardType.values()) {
            if (Objects.equals(c.getName(), name)) {
                return c.code;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
